//
//  WelcomeViewController.swift
//  WeiBo(Swift)
//
//  Created by 周成龙 on 16/9/28.
//  Copyright © 2016年 ZCL. All rights reserved.
//

import UIKit

import SDWebImage

class WelcomeViewController: UIViewController {

    
    @IBOutlet weak var iconImageView: UIImageView!
    
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var iconImageViewBottom: NSLayoutConstraint!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        titleLabel.alpha = 0.0
        
        iconImageView.layer.cornerRadius = 45
        iconImageView.layer.masksToBounds = true
        
        guard let url = URL(string: (UserAccount.loadAccount()?.avatar_large)!) else {
            return
        }
        iconImageView.sd_setImage(with: url, placeholderImage: UIImage(named: "avatar_default_big"))
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        UIView.animate(withDuration: 2.0, animations: { 
            self.iconImageViewBottom.constant = UIScreen.main.bounds.height - self.iconImageViewBottom.constant
            self.view.layoutIfNeeded()
            
            }) { (_) in
                
                UIView.animate(withDuration: 1.0, animations: {
                    self.titleLabel.alpha = 1.0
                    }, completion: { (_) in
                        ZLog(message: "")
                })
        }
    }

}
